package com.content.Controller.show;

import com.common.Entity.Result;
import com.content.Entity.show.Program;
import com.content.Entity.show.ProgramType;
import com.content.Entity.show.UpdateOrder;
import com.content.Service.show.ProgramService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/program")
public class ProgramController {
    @Autowired
    private ProgramService programService;


    @GetMapping("/getProgramList")
    public Result getProgramList(@RequestParam Integer pageNum,
                                 @RequestParam Integer pageSize,
                                 @RequestParam(required = false) String programName,
                                 @RequestParam String selectedShowId) {
        PageInfo<Program> pageInfo = programService.getProgramList(pageNum, pageSize, programName,selectedShowId);
        return Result.success(pageInfo);
    }

    @PostMapping("/addProgram")
    public Result addProgram(@RequestBody Program program) {
        programService.addProgram(program);
        return Result.success();
    }

    @PutMapping("/updateProgram")
    public Result updateProgram(@RequestBody Program program) {
        programService.updateProgram(program);
        return Result.success();
    }

//    @PutMapping("/updateProgramOrder/{programId}")
//    public Result updateProgramOrder(@PathVariable("programId") String programId,@RequestBody String orderNo) {
//        programService.updateProgramOrder(programId,orderNo);
//        return Result.success();
//    }
@PutMapping("/updateProgramOrder")
public Result updateProgramOrder(@RequestBody UpdateOrder updateOrder) {
    programService.updateProgramOrder(updateOrder);
    return Result.success();
}
    @DeleteMapping("/deleteProgram/{programId}")
    public Result deleteProgram(@PathVariable String programId) {
        programService.deleteProgram(programId);
        return Result.success();
    }

    @GetMapping("/getProgramListById/{showId}")
    public Result getProgramListById(@PathVariable("showId") String showId) {
        List<Program> list = programService.getProgramListById(showId);
        return Result.success(list);
    }



    @GetMapping("/getProgramTypeList")
    public Result getProgramTypeList(@RequestParam Integer pageNum,
                                     @RequestParam Integer pageSize,
                                     @RequestParam(required = false) String programTypeName) {
        PageInfo<ProgramType> pageInfo = programService.getProgramTypeList(pageNum, pageSize, programTypeName);
        return Result.success(pageInfo);
    }

    @GetMapping("/getProgramTypes")
    public Result<List<ProgramType>> getProgramTypeList() {
        List<ProgramType> list = programService.getProgramTypeLists();
        return Result.success(list);
    }



    @PostMapping("/addProgramType")
    public Result addProgramType(@RequestBody ProgramType programType) {
        programService.addProgramType(programType);
        return Result.success();
    }
    @PutMapping("/updateProgramType")
    public Result updateProgramType(@RequestBody ProgramType programType) {
        programService.updateProgramType(programType);
        return Result.success();
    }
    @DeleteMapping("/deleteProgramType/{programTypeId}")
    public Result deleteProgramType(@PathVariable("programTypeId") String programTypeId) {
        programService.deleteProgramType(programTypeId);
        return Result.success();
    }


}
